package com.chenhao.springcloud.chenhaodesignservice.pattern.structural.facade;

/**
 * Description:
 *
 * @author chenhao
 * @date 2020/12/22 14:14
 */
public class GiftExchangeService {
    private QualifyService qualifyService;
    private PonitsPaymentService ponitsPaymentService;
    private ShippingService shippingService;

    public QualifyService getQualifyService() {
        return qualifyService;
    }

    public void setQualifyService(QualifyService qualifyService) {
        this.qualifyService = qualifyService;
    }

    public PonitsPaymentService getPonitsPaymentService() {
        return ponitsPaymentService;
    }

    public void setPonitsPaymentService(PonitsPaymentService ponitsPaymentService) {
        this.ponitsPaymentService = ponitsPaymentService;
    }

    public ShippingService getShippingService() {
        return shippingService;
    }

    public void setShippingService(ShippingService shippingService) {
        this.shippingService = shippingService;
    }

    public void giftExchange(PointsGift pointsGift){
        if (qualifyService.isAvailable(pointsGift)){
            if (getPonitsPaymentService().pay(pointsGift)){
                // 如果支付积分成功
                String shippingOrderNo = shippingService.shipGift(pointsGift);
                System.out.println("物流系统下单成功，订单号是"+shippingOrderNo);
            }
        }
    }
}
